import { useState, useEffect } from 'react'

function useInit (init, initState = []) {
  const [list, setList] = useState(initState)
  useEffect(() => {
    init().then(({ data }) => {
      setList(data)
    })
  }, [])
  return [list]
}

export { useInit }
